package com.teach;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Arrays;

public class Test4 {

	public static void main(String[] args) {
		/**
		 * in.txt ABC\nabc 65,66,67,13,10,97,98,99
		 */
		File f1 = new File("d:/upload/in.txt");
		File f2 = new File("d:/upload/out.txt");

		try (OutputStream out = new FileOutputStream(f2);) {
			out.write(65);
			out.write(69);
			out.write('中');
			out.write('X');
			out.write(13);
			out.write(10);
			out.write('y');
			out.write('z');
			out.write(-42);
			out.write(-48);
			System.out.println((int) '中');
			System.out.println((byte) '中');
			System.out.println(Arrays.toString("中".getBytes()));
			System.out.println(Arrays.toString("中".getBytes("UTF-8")));
			System.out.println(Arrays.toString("中".getBytes("GBK")));
		} catch (Exception e) {
			e.printStackTrace();
		}

		try (OutputStream out = new FileOutputStream(new File("d:/upload/out1.txt"));) {
			byte[] bs = {65,66,67,13,10,97,98,99};
			out.write(bs);
			bs = "\n\r中华人民共和国".getBytes();
			out.write(bs);
			bs = "\n\r中华人民共和国".getBytes("GBK");
			out.write(bs);
//			out.write(bs, 0, bs.length);//=out.write(bs);
			out.write(bs, 0, 4);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
